#include <iostream>
#include <unistd.h>
#include <vector>
#include <sys/types.h>
using namespace std;

const int cnt = 10;

void sub_process_run(){
    while(true){
        cout << "I am subprocess,pid: " << getpid() << ",ppid: " << getppid() << endl;
        sleep(5);
    }
}

int main(){
    vector<pid_t> sub_process;
    for(int i = 0;i < cnt; ++i){
        pid_t id = fork();
        if(id == 0){
            sub_process_run();
        }
        sub_process.push_back(id);
    }
    cout << "my subprocess pid: ";
    for(auto p : sub_process){
        cout << p << " ";
    }
    cout << endl;
    sleep(10);
    while(true){
        cout << "my pid is:" << getpid() << endl;
        sleep(1);
    }
    return 0;
}
